<!DOCTYPE html>
<html lang="zh-CN"{:dark_css()}>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>{:site('site_title')}</title>
    <meta name="keywords" content="{:site('site_kw')}">
    <meta name="description" content="{:site('site_desc')}">
    <link href="__STATIC__/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="__STATIC__/nprogress/nprogress.css" rel="stylesheet">
    <link href="__STATIC__/cherry/cherry-markdown.min.css" rel="stylesheet">
    <link href="__STATIC__/css/aphp-doc.css?v={:site_ver()}" rel="stylesheet">
    {php $book_id=input('get.book_id',0,'intval')}
    {php $doc_id=get_start_id($book_id)}
    <script>
        const GV = {
            doc_id : '{$doc_id}',
            book_id : '{$book_id}',
            upload_api: "{:url('api/upload')}",
            base_href: "{:url('doc/add')}",
        }
    </script>
    <style>
        #markdown-editor {
            width: 100%;
            margin: 0 auto;
        }
        .article-info {
            height: 45px;
        }
        @media screen and (min-width: 1450px) {
            .m-manual .manual-right .manual-article {
                margin-right: 0;
            }
            .article-info .pull-left {
                padding-left: 75px;
                font-weight: bold;
            }
        }
        .manual-article .article-content {
            max-width: none;
            width: 100%;
        }
    </style>
</head>
<body>
<div class="m-manual manual-mode-view manual-reader">
    <header class="navbar navbar-static-top manual-head transition">
        <div class="container-fluid">
            <div class="navbar-header pull-left manual-title">
                <span class="sidebarToggle" id="sidebarToggle"><i class="glyphicon glyphicon-align-justify"></i></span>
                <a href="{:url('doc/read', ['id'=>$doc_id])}" id="book-title">{$book.title}</a>
                <span class="book-ver">{$book.version}</span>
            </div>
            <div class="navbar-header pull-right manual-menu">
                <div class="doc-menu-item">
                    <a href="{:url('index/index')}" class="btn btn-link">
                        <i class="glyphicon glyphicon-home"></i> 首页
                    </a>
                    <a href="javascript:;" class="btn btn-link btn-theme">
                        <span class="tooltips sun" title="切换浅色模式" data-placement="bottom"><i class="glyphicon glyphicon-adjust"></i> 浅色</span>
                        <span class="tooltips moon" title="切换深色模式" data-placement="bottom"><i class="glyphicon glyphicon-adjust"></i> 深色</span>
                    </a>
                    {if !session('user.id'):}
                    <a href="{:url('user/login')}" class="btn btn-link">
                        <i class="glyphicon glyphicon-log-in"></i> 登录
                    </a>
                    {else:}
                    <a href="javascript:ajaxConfirm('{:url('user/logout')}','退出');" class="btn btn-link">
                        <i class="glyphicon glyphicon-log-out"></i> 退出
                    </a>
                    {/if}
                </div>
            </div>
        </div>
    </header>
    <div class="container-fluid manual-body">
        <div class="manual-right transition">
            <div class="manual-article">
                <div class="article-content">
                    <div class="help-block article-info">
                        <span class="pull-left">
                            <a href="{:url('doc/add',['book_id'=>$book_id])}">新增文档</a> | <a href="{:url('doc/read',['id'=>$doc_id])}">查看文档</a>
                        </span>
                        <span class="pull-right">
                            <a href="{:url('doc/read',['id'=>$doc_id])}"><i class="glyphicon glyphicon-backward"></i> 返回</a>
                        </span>
                    </div>
                    <div id="doc_edit">
                        <form class="form-horizontal submit-ajax" role="form" action="{:url('add')}" method="post">
                            <input type="hidden" name="book_id" value="{$book.id}"/>
                            <div class="form-group">
                                <label for="pid" class="col-sm-1 control-label">*上级</label>
                                <div class="col-sm-11">
                                    {:form_select('pid', widget('common.book_dir')->get($book_id,['get_type'=>1]), '0', ' class="form-control" style="width:200px;"')}
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="title" class="col-sm-1 control-label">*标题</label>
                                <div class="col-sm-11">
                                    <input type="text" id="title" name="title" class="form-control" placeholder="请输入文档标题" value="新的文档" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="sign" class="col-sm-1 control-label">*标识</label>
                                <div class="col-sm-11">
                                    <input type="text" id="sign" name="sign" class="form-control" placeholder="标识名称(下载用)" value="new" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label">*内容</label>
                                <div class="col-sm-11">
                                    <div id="markdown-editor"></div>
                                    <textarea id="markdown-content" name="markdown" style="display: none;"></textarea>
                                    <textarea id="html-content" name="html" style="display: none;"></textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="summary" class="col-sm-1 control-label">摘要</label>
                                <div class="col-sm-11">
                                    <textarea name="summary" id="summary" rows="2" class="form-control" placeholder="文档摘要，为空自动获取"></textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="sort" class="col-sm-1 control-label">*排序</label>
                                <div class="col-sm-11">
                                    <input type="text" id="sort" name="sort" class="form-control" placeholder="排序值(越小排越前)" value="100" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label">&nbsp;</label>
                                <div class="col-sm-11">
                                    <input type="submit" id="submit" value="添加" class="btn btn-primary" />
                                </div>
                            </div>
                        </form>
                    </div>

                    <div class="jump-bars">
                        <ul>
                            <li class="visible-xs visible-sm bars-menu bars-menu-hide">
                                <a href="{:url('index/index')}" title="首页"><i class="glyphicon glyphicon-home"></i></a>
                            </li>
                            <li class="book-menu visible-xs visible-sm">
                                <a href="javascript:;" title="菜单"><i class="glyphicon glyphicon-align-justify"></i></a>
                            </li>
                            <li class="book-theme visible-xs visible-sm">
                                <a href="javascript:;" title="样式"><i class="glyphicon glyphicon-adjust"></i></a>
                            </li>
                            <li>
                                <a href="javascript:;" class="view-backtop"><i class="glyphicon glyphicon-arrow-up" aria-hidden="true"></i></a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>

        <div class="manual-left">
            <div class="article-search">
                <form id="searchForm" action="{:url('doc/search')}" method="post">
                    <div class="input-group">
                        <input type="hidden" name="book_id" value="{$book_id}">
                        <input type="text" name="keyword" placeholder="搜索关键字..." autocomplete="off" class="form-control">
                        <span class="input-group-addon input-group-addon-clear"><i class="glyphicon glyphicon-remove"></i></span>
                        <span class="input-group-addon">
                            <button type="submit"><i class="glyphicon glyphicon-search"></i></button>
                        </span>
                    </div>
                </form>
                <div class="pull-right hidden-xs" id="catalogToggle">
                    <i class="glyphicon glyphicon-align-justify"></i>
                </div>
            </div>
            <div class="article-menu">
                <div class="article-menu-detail collapse-menu">
                    {php $tree=widget('common.book_dir')->get($book_id)}
                    {include file='doc/_dir_read.html'}
                </div>
                <div class="search-result">
                    <div class="search-empty" style="display: block;">
                        <i class="glyphicon glyphicon-search-plus" aria-hidden="true"></i>
                        <b class="text">暂无相关搜索结果！</b>
                    </div>
                    <ul class="search-list" id="searchList"></ul>
                </div>
            </div>
            <div class="m-copyright">
                <p>
                    本文档使用 <a href="//doc.aphp.top" target="_blank">AphpDoc</a> 构建
                </p>
            </div>
        </div>
        <div class="manual-progress transition"><b class="progress-bar"></b></div>
    </div>
    <div class="manual-mask"></div>
</div>

<script src="__STATIC__/js/jquery-3.7.1.min.js"></script>
<script src="__STATIC__/bootstrap/js/bootstrap.min.js"></script>
<script src="__STATIC__/layer_mobile/layer.js"></script>
<script src="__STATIC__/js/aphp-1.1.js?v={:site_ver()}"></script>
<script src="__STATIC__/nprogress/nprogress.js"></script>
<script src="__STATIC__/cherry/cherry-markdown.core.js"></script>
<script src="__STATIC__/js/cherry_editor.js"></script>
<script src="__STATIC__/js/doc_common.js"></script>
<script>
    $(function () {
        // 搜索结果
        $("#searchList").on("click", "a", function () {
            let id = $(this).attr("data-id");
            location.href = "{:url('doc/read')}?id=" + id;
        });
    });
</script>
</body>
</html>